#ifndef _SCOPE_TIMER_H_
#define _SCOPE_TIMER_H_

#include <arduino/Arduino.h>


namespace utils
{

class scope_timer
{
public:

  scope_timer(unsigned long duration_ms)
    : _duration(duration_ms)
    , _begin(millis()){}

  ~scope_timer(void)
  {
    int to_wait = _duration - (millis() - _begin);
    if (to_wait > 0) delay(to_wait);
  }

private:

  unsigned long _duration;
  unsigned long _begin;
};

} // utils

#endif // _SCOPE_TIMER_H_
